//
//  MarketTableViewCell.m
//  EggSteward
//
//  Created by 王道林 on 16/9/7.
//  Copyright © 2016年 王道林. All rights reserved.
//

#import "MarketTableViewCell.h"
#import "BaseLabel.h"
#import "Masonry.h"

@interface MarketTableViewCell ()

@property (nonatomic, strong) BaseLabel *lablePrice;
@property (nonatomic, strong) BaseLabel *lableWeek;
@property (nonatomic, strong) BaseLabel *lableMoney;
@end

@implementation MarketTableViewCell


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubview];
    }
    return self;
}

- (void)createSubview
{
    _lableClass = [[BaseLabel alloc] init];
    [self.contentView addSubview:_lableClass];
    
    _lablePrice = [[BaseLabel alloc] init];
    [self.contentView addSubview:_lablePrice];
    
    _lableWeek = [[BaseLabel alloc] init];
    _lableWeek.textColor = [UIColor grayColor];
    [self.contentView addSubview:_lableWeek];
    
    _lableMoney = [[BaseLabel alloc] init];
    _lableMoney.textColor = [UIColor grayColor];
    [self.contentView addSubview:_lableMoney];
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    [_lableClass mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.contentView.mas_top);
        make.left.mas_equalTo(self.contentView.mas_left).mas_offset(5);
        make.width.mas_equalTo(self.contentView.mas_width).multipliedBy(0.5).mas_offset(-10);
        make.height.mas_equalTo(self.contentView.mas_height).multipliedBy(0.5);
    }];
    
    [_lablePrice mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.contentView.mas_top);
        make.right.mas_equalTo(self.contentView.mas_right).mas_offset(-5);
        make.width.mas_equalTo(self.contentView.mas_width).multipliedBy(0.5).mas_offset(-10);
        make.height.mas_equalTo(self.contentView.mas_height).multipliedBy(0.5);
    }];
    
    [_lableWeek mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(self.contentView.mas_bottom);
        make.left.mas_equalTo(self.contentView.mas_left).mas_offset(5);
        make.width.mas_equalTo(self.contentView.mas_width).multipliedBy(0.5).mas_offset(-10);
        make.height.mas_equalTo(self.contentView.mas_height).multipliedBy(0.5);
    }];
    
    [_lableMoney mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(self.contentView.mas_bottom);
        make.right.mas_equalTo(self.contentView.mas_right).mas_offset(-5);
        make.width.mas_equalTo(self.contentView.mas_width).multipliedBy(0.5).mas_offset(-10);
        make.height.mas_equalTo(self.contentView.mas_height).multipliedBy(0.5);
    }];
}

- (void)setDic:(NSDictionary *)dic
{
    _dic = dic;
    NSString *stringPrice = [NSString stringWithFormat:@"均价 : %@", _dic[@"d"]];
    NSString *stringWeek = [NSString stringWithFormat:@"周均价 : %@", _dic[@"w"]];
    NSString *stringMoney = [NSString stringWithFormat:@"月均价 : %@", _dic[@"m"]];
    _lablePrice.text = stringPrice;
    _lableWeek.text = stringWeek;
    _lableMoney.text = stringMoney;
}


@end
